<template>
	<view>
		<view class="bg"></view>
		<view class="container">

			<view class="list">
				<view class="col" v-for="item in list" @click="goDetail(item)">
					<image :src="item.image" mode="aspectFill"></image>
					<view class="text">
						<view class="title ovh2">
							{{item.title}}
						</view>
						<view class="time">
							{{item.date}}
						</view>
					</view>
				</view>
			</view>
			<uni-load-more :status="status"></uni-load-more>
		</view>
		<tabbar active='2'></tabbar>
	</view>
</template>

<script>
	import tabbar from "@/components/tabbar_staff.vue"
	export default {
		components: {
			tabbar
		},

		data() {
			return {
				list: [],
				page: 1,
				status: "no-more"
			}
		},
		onShow() {
			uni.hideHomeButton()
			this.init()
		},
		onPullDownRefresh() {
			this.init()
		},
		onReachBottom() {
			this.page++
			this.getList()
		},
		methods: {
			init() {
				this.list = []
				this.page = 1
				this.getList()
			},
			getList() {
				this.status = "loading"
				this.$post("/index/article_data", {
					page: this.page,
					category: 'study'
				}).then(res => {
					this.status = "no-more"
					uni.stopPullDownRefresh()
					res.data.data.forEach(item => {
						item.checked = false
						this.list.push(item)
					})
				})
			},
			goDetail(item) {
				uni.navigateTo({
					url: "./detail?article_id=" + item.article_id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.bg {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 500rpx;
		background: linear-gradient(#3670F6 70%, transparent);
	}

	.container {
		padding: 0 20rpx;
	}

	.list {
		padding: 0 40rpx;
		background-color: #fff;
		padding: 20rpx;
		position: relative;
		background: #FFFFFF;
		border-radius: 20rpx;

		.col {
			display: flex;
			align-items: center;
			padding: 30rpx 0;
			border-bottom: 1rpx solid #eee;

			image {
				width: 240rpx;
				height: 180rpx;
				border-radius: 20rpx;
			}

			.text {
				width: calc(100% - 240rpx);
				padding-left: 42rpx;

				.title {
					font-weight: bold;
					font-size: 32rpx;
					line-height: 45rpx;
				}

				.time {
					color: #B7B7B7;
					font-size: 26rpx;
					margin-top: 20rpx;
				}
			}
		}
	}
</style>